﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Interface_Tier;
using Transfer_Object_Tier;

namespace eSolution_HRMSS.Winforms.QuaTrinhLamViec
{
    public partial class FR_QuaTrinhDaoTao : DevExpress.XtraEditors.XtraForm
    {
        IHRM_PROCESS_TRAININGData _IHRM_PROCESS_TRAININGData;
        ICommonCode _icommon;
        eSolution_HRMSS.HRMSS_Ultil util = new HRMSS_Ultil();
        Guid currentId;
        Guid new_id;
        bool isUpdate = false;
         public FR_QuaTrinhDaoTao(bool _isUpdate)
        {
            InitializeComponent();
            isUpdate = _isUpdate;
        }

         public FR_QuaTrinhDaoTao(bool _isUpdate, Guid _currentId)
        {
            InitializeComponent();
            isUpdate = _isUpdate;
            currentId = _currentId;
        }

        private void FR_QuaTrinhDaoTao_Load(object sender, EventArgs e)
        {
            _IHRM_PROCESS_TRAININGData = (IHRM_PROCESS_TRAININGData)Activator.GetObject(typeof(IHRM_PROCESS_TRAININGData), util.ChuoiPROCESS_TRAININGData);
            _icommon = (ICommonCode)Activator.GetObject(typeof(ICommonCode), util.Chuoicommon);
        }
        private HRM_PROCESS_TRAINING lay_thong_tin()
        {
            string veviec = txtveviec.Text;
            string lydo = txtlydo.Text;
            string hinhthucdaotao = txthinhthucdaotao.Text;
            string thoigiandaotao = txtthoigiandaotao.Text;
            string soquyetdinh = txtsoquyetdinh.Text;
            string nguoibanhanh = txtnguoibanhanh.Text;

            DateTime ngaybatdau = dtngaybatdau.DateTime;
            DateTime ngaybanhanh = dtngaybanhanh.DateTime;

            HRM_PROCESS_TRAINING process_training = new HRM_PROCESS_TRAINING();
            process_training.BeginDate = ngaybatdau;
            process_training.Date = ngaybanhanh;
            process_training.TrainingName= veviec;
            process_training.Reason = lydo;
            process_training.Form = hinhthucdaotao;
            process_training.Time = thoigiandaotao;
            process_training.DecideNumber = soquyetdinh;
            process_training.Person = nguoibanhanh;
            return process_training;
        }
        private void load_info()
        {
            DataTable dt = _IHRM_PROCESS_TRAININGData.HRM_PROCESS_TRAINING_Get(currentId).Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                txthinhthucdaotao.Text = dr["Form"].ToString();
                txtveviec.Text = dr["TrainingName"].ToString();
                txtlydo.Text = dr["Reason"].ToString();
                txtthoigiandaotao.Text=dr["Time"].ToString();
                txtsoquyetdinh.Text=dr["DecideNumber"].ToString();
                txtnguoibanhanh.Text = dr["Person"].ToString();
                dtngaybatdau.DateTime = DateTime.Parse(dr["BeginDate"].ToString());
                dtngaybanhanh.DateTime = DateTime.Parse(dr["Date"].ToString());
            }
        }
    }
}